package cn.dlc.com.mapper;

import cn.dlc.com.pojo.SysPermission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author deng
 * @date 2021/6/29 9:19
 **/
public interface SysPermissionMapper extends BaseMapper<SysPermission> {

    /**
     * 获取用户权限列表
     * @param userId
     * @return
     */
    @Select("select sp.id as id, sp.permission_name as permissionName, sp.permission_url as permissionUrl" +
            " from sys_permission sp " +
            "LEFT JOIN sys_role_permission srp  on srp.pid = sp.id " +
            "left join sys_user_role sur on sur.rid = srp.rid " +
            "where sur.uid = #{userId}")
    List<SysPermission> findPermissionsByUserId(Long userId);

}
